package win.zxshuo.www.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

/**
 * Author:rffanlab
 * Created:2018/3/30
 */
@Entity
@Table(name = "user",indexes ={
        @Index(name = "token_index",columnList="token",unique = true),
        @Index(name = "username_index",columnList="username",unique = true),
        @Index(name = "mobile_index",columnList="mobile",unique = true),
        @Index(name = "wxopenid_index",columnList = "wxOpenid",unique = true)
})
public class UserModel  implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(updatable = false)
    private Date createDate;

    private Date modifyDate;

    @Column(columnDefinition = "varchar(100)")
    private String username;

    @Column(columnDefinition = "varchar(100)")
    private String mobile;

    private String password;

    @Column(columnDefinition = "varchar(100)")
    private String wxOpenid;

    @Column(columnDefinition = "varchar(100)")
    private String token;

    @OneToMany(mappedBy = "userModel", cascade = CascadeType.ALL)
    private Set<BookShelfModel> bookShelfModels;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getWxOpenid() {
        return wxOpenid;
    }

    public void setWxOpenid(String wxOpenid) {
        this.wxOpenid = wxOpenid;
    }

    public Set<BookShelfModel> getBookShelfModels() {
        return bookShelfModels;
    }

    public void setBookShelfModels(Set<BookShelfModel> bookShelfModels) {
        this.bookShelfModels = bookShelfModels;
    }
}
